<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition template="#{webGlobal.url_template}/default/main.xhtml">
	<ui:define name="head">
		<link href="#{webGlobal.url_module}/team/r/css/main.css" rel="stylesheet" />
	</ui:define>
	
	<ui:define name="content">
		<div class="main-container" style="margin: 0 auto;">
			<div class="container" style="margin:200px auto;">
				<div class="panel panel-default">
					<div class="panel-heading">Liste des matches</div>
					
					<h:panelGroup rendered="#{tournamentDetail.listMatch.size() == 0}">
						<div class="panel-body">Aucun match dans ce tournoi</div>
					</h:panelGroup>
					<h:panelGroup rendered="#{tournamentDetail.listMatch.size() > 0}">
						<table class="table">
							<thead>
								<tr>
									<th style="text-align: center;">Tour</th>
									<th style="text-align: center;">Equipe domicile</th>
									<th style="text-align: center;">Equipe exterieur</th>
									<th style="text-align: center;">Score</th>
									<th style="text-align: center;">Arbitre</th>
									<th style="text-align: center;">Action</th>
								</tr>
							</thead>
							<tbody>
								<ui:repeat var="match" value="#{tournamentDetail.listMatch}">
									<tr>
										<td>#{match.roundNumber}</td>
										<td>#{match.homeTeam.name}</td>
										<td>#{match.outsideTeam.name}</td>
										<td>#{match.scoreHome} - #{match.scoreOutside}</td>
										<td>#{match.referee.toString()}</td>
										<td>
											<h:form prependId="false">
												<h:commandButton action="#{tournamentDetail.goToDetailMatch(match)}"
												image="#{webGlobal.url_module}/tournament/img/edit-icon.png"
												style="height: 20px; width: 20px; vertical-align: top;" />
											</h:form>
										</td>
									</tr>
								</ui:repeat>
								<tr></tr>
							</tbody>
						</table>
					</h:panelGroup>
				</div>
				
				<div class="panel panel-default">
					<div class="panel-heading">Liste des équipes</div>
					
					<h:panelGroup rendered="#{tournamentDetail.listTeam.size() == 0}">
						<div class="panel-body">Aucun match dans ce tournoi</div>
					</h:panelGroup>
					<h:panelGroup rendered="#{tournamentDetail.listTeam.size() > 0}">
						<table class="table">
							<thead>
								<tr>
									<th style="text-align: center;">Nom</th>
									<th style="text-align: center;">Représentant</th>
									<th style="text-align: center;">Actions</th>
								</tr>
							</thead>
							<tbody>
								<ui:repeat var="team" value="#{tournamentDetail.listTeam}">
									<tr>
										<td>#{team.name}</td>
										<h:panelGroup rendered="#{tournamentDetail.mapTeamStaff[team] == null}">
											<td style="color: gray;">Non renseigné</td>
										</h:panelGroup>
										<h:panelGroup rendered="#{tournamentDetail.mapTeamStaff[team] != null}">
											<td>#{tournamentDetail.mapTeamStaff[team].firstName} #{tournamentDetail.mapTeamStaff[team].lastName}</td>
										</h:panelGroup>
										<td>
											<h:form prependId="false">
												<h:commandButton action="#{tournamentDetail.goToDetailTeam(team)}"
												image="#{webGlobal.url_module}/tournament/img/edit-icon.png"
												style="height: 20px; width: 20px; vertical-align: top;" />
											</h:form>
										</td>
									</tr>
								</ui:repeat>
								<tr></tr>
							</tbody>
						</table>
					</h:panelGroup>
				</div>
				<h:outputLink value="#{webGlobal.url_module}/public/choiceTournament.jsf" 
				    	styleClass="btn btn-lg btn-primary btn-block">Retour aux tournois</h:outputLink>
		    </div>
		</div>
 	</ui:define>
</ui:composition>
</html>